﻿package App;

import android.app.Application;
import android.content.Context;
import android.os.Handler;

/**
 * Created by Administrator on 2017/3/23.

diao

 */
public class MyApplication extends Application{
    private static Context context;//上下文
    private static Handler mHandler;//线程通信工具
    private static Thread mainThread;//主线程
    private static int mainThreadId;//主线程的id

    //初始化时;
    public void onCreate() {

        //实例化;
        context=this.getApplicationContext();
        mHandler=new Handler();
        mainThread=Thread.currentThread();//取得当前的线程
        mainThreadId=android.os.Process.myTid();//取得当前的线程的id
    }

    //提供方法给外面使用;
    public static Context getContext() {
        return context;
    }
    public static Handler getHandler() {
        return mHandler;
    }
    public static Thread getMainThread() {
        return mainThread;
    }
    public static int getMainThreadId() {
        return mainThreadId;
    }

}
